# eric7.Plugins.UiExtensionPlugins.Translator.TranslatorWidget

Module implementing the translator widget.

### Global Attributes

MultimediaAvailable

### Classes

TranslatorWidget | Class implementing the translator widget.

### Functions

None

## TranslatorWidget

Class implementing the translator widget.

### Derived from

QWidget, Ui_TranslatorWidget

### Class Attributes

None

### Class Methods

None

### Methods

TranslatorWidget | Constructor
__availableTranslationsLoaded | Private slot to handle the availability of translations.
__engineComboBoxCurrentIndexChanged | Private slot to handle the selection of a translation service.
__ensureTranslationEngineReady | Private slot to ensure, that the currently selected translation engine is ready.
__mediaPlayerError | Private slot to handle errors during playback of the data.
__mediaPlayerPlaybackStateChanged | Private slot handling changes of the media player state.
__originalLanguage | Private method to return the code of the selected original language.
__pronounce | Private method to pronounce the given text.
__translate | Private method to translate the given text.
__translationLanguage | Private method to return the code of the selected translation language.
__updateClearButton | Private slot to set the state of the clear button.
__updateEngines | Private slot to update the engines combo box.
__updateLanguages | Private slot to update the language combo boxes.
__updatePronounceButtons | Private slot to set the state of the pronounce buttons.
__updateTranslateButton | Private slot to set the state of the translate button.
on_clearButton_clicked | Private slot to clear the text fields.
on_origEdit_textChanged | Private slot to handle changes of the original text.
on_origLanguageComboBox_currentIndexChanged | Private slot to handle the selection of the original language.
on_preferencesButton_clicked | Private slot to open the Translator configuration page.
on_pronounceOrigButton_clicked | Private slot to pronounce the original text.
on_pronounceTransButton_clicked | Private slot to pronounce the translated text.
on_swapButton_clicked | Private slot to swap the languages.
on_transEdit_textChanged | Private slot to handle changes of the translation text.
on_transLanguageComboBox_currentIndexChanged | Private slot to handle the selection of the translation language.
on_translateButton_clicked | Private slot to translate the entered text.

### Static Methods

None

#### TranslatorWidget (Constructor)

TranslatorWidget(plugin, translator, parent=None)

Constructor

plugin (TranslatorPlugin)
  reference to the plugin object
translator (Translator)
  reference to the translator object
parent (QWidget)
  reference to the parent widget

#### TranslatorWidget.__availableTranslationsLoaded

__availableTranslationsLoaded()

Private slot to handle the availability of translations.

#### TranslatorWidget.__engineComboBoxCurrentIndexChanged

__engineComboBoxCurrentIndexChanged(index)

Private slot to handle the selection of a translation service.

index (int)
  current index

#### TranslatorWidget.__ensureTranslationEngineReady

__ensureTranslationEngineReady()

Private slot to ensure, that the currently selected translation engine is ready.

#### TranslatorWidget.__mediaPlayerError

__mediaPlayerError(error, errorString)

Private slot to handle errors during playback of the data.

error (QMediaPlayer.Error)
  media player error condition
errorString (str)
  string representation for the error

#### TranslatorWidget.__mediaPlayerPlaybackStateChanged

__mediaPlayerPlaybackStateChanged(state)

Private slot handling changes of the media player state.

state (QMediaPlayer.PlaybackState)
  media player state

#### TranslatorWidget.__originalLanguage

__originalLanguage()

Private method to return the code of the selected original language.

Return:
  code of the original language

Return Type:
  str

#### TranslatorWidget.__pronounce

__pronounce(text, language)

Private method to pronounce the given text.

text (str)
  text to be pronounced
language (str)
  language code of the text

#### TranslatorWidget.__translate

__translate(text, originalLanguage, translationLanguage)

Private method to translate the given text.

text (str)
  text to be translated
originalLanguage (str)
  language code of the original
translationLanguage (str)
  language code of the translation

Return:
  tuple of translated text and flag indicating success

Return Type:
  tuple of (str, bool)

#### TranslatorWidget.__translationLanguage

__translationLanguage()

Private method to return the code of the selected translation language.

Return:
  code of the translation language

Return Type:
  str

#### TranslatorWidget.__updateClearButton

__updateClearButton()

Private slot to set the state of the clear button.

#### TranslatorWidget.__updateEngines

__updateEngines()

Private slot to update the engines combo box.

#### TranslatorWidget.__updateLanguages

__updateLanguages()

Private slot to update the language combo boxes.

#### TranslatorWidget.__updatePronounceButtons

__updatePronounceButtons()

Private slot to set the state of the pronounce buttons.

#### TranslatorWidget.__updateTranslateButton

__updateTranslateButton()

Private slot to set the state of the translate button.

#### TranslatorWidget.on_clearButton_clicked

on_clearButton_clicked()

Private slot to clear the text fields.

#### TranslatorWidget.on_origEdit_textChanged

on_origEdit_textChanged()

Private slot to handle changes of the original text.

#### TranslatorWidget.on_origLanguageComboBox_currentIndexChanged

on_origLanguageComboBox_currentIndexChanged(index)

Private slot to handle the selection of the original language.

index (int)
  current index

#### TranslatorWidget.on_preferencesButton_clicked

on_preferencesButton_clicked()

Private slot to open the Translator configuration page.

#### TranslatorWidget.on_pronounceOrigButton_clicked

on_pronounceOrigButton_clicked()

Private slot to pronounce the original text.

#### TranslatorWidget.on_pronounceTransButton_clicked

on_pronounceTransButton_clicked()

Private slot to pronounce the translated text.

#### TranslatorWidget.on_swapButton_clicked

on_swapButton_clicked()

Private slot to swap the languages.

#### TranslatorWidget.on_transEdit_textChanged

on_transEdit_textChanged()

Private slot to handle changes of the translation text.

#### TranslatorWidget.on_transLanguageComboBox_currentIndexChanged

on_transLanguageComboBox_currentIndexChanged(index)

Private slot to handle the selection of the translation language.

index (int)
  current index

#### TranslatorWidget.on_translateButton_clicked

on_translateButton_clicked()

Private slot to translate the entered text.

Up